package io.renren.minimito.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.minimito.dao.AdBannerDao;
import io.renren.minimito.entity.AdBannerEntity;
import io.renren.minimito.entity.UmAreaEntity;
import io.renren.minimito.service.AdBannerService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("adBannerService")
public class AdBannerServiceImpl extends ServiceImpl<AdBannerDao, AdBannerEntity> implements AdBannerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<AdBannerEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            wrapper.like("banner_name",key);
        }


        IPage<AdBannerEntity> page = this.page(
                new Query<AdBannerEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}